<%-- 
    Document   : doGetCandidati
    Created on : 17-mag-2014, 17.52.09
    Author     : Albo
--%>

<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="it.polimi.Mir_1.paw.DBconnect"%>


<%
        
    String partito=request.getParameter("partito");
   
    
    
          DBconnect connAlbo = new DBconnect();
       // CONNESSIONE AL DATABASE
       Connection conn = connAlbo.getConnection();
       
      
       
      List <String> candidati =connAlbo.getCandidatibyPartito(partito,conn);
       if (candidati != null){
      out.print("{\"dati\":[");
      for(int i=0; i<candidati.size(); i++)
          {
               out.print("\"");
               out.print(candidati.get(i));
               out.print("\"");
               if (i != candidati.size()-1){
                     out.print(",");
               }
               
          }
       out.print("]}");
       }
       
            conn.close();
%>


